//
//  DKMainCustomerServiceController.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/23.
//

#import "DKMainCustomerServiceController.h"
#import "DKMainSigleInfoView.h"
@interface DKMainCustomerServiceController ()
@property (nonatomic, strong)DKMainSigleInfoView * dk_MainSiglePhoneView;
@property (nonatomic, strong)DKMainSigleInfoView * dk_MainSigleEmailView;
@end

@implementation DKMainCustomerServiceController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
    [self makeNavBack];
    [self dk_addSubView];
    [self requestComplaint];
    [DKPublicHttp apiUserBrhavRecordForAPI:@{} withPageName:DK_CustomerService withAction:DK_ActionEnter complete:^{
            
    } fail:^{
            
    }];
}
- (void)dk_addSubView{
    UILabel * dk_ComplaintHeadLab = [[UILabel alloc] init];
    dk_ComplaintHeadLab.textColor = DK_Hex(@"#333333");
    dk_ComplaintHeadLab.font = DK_FONT_Medium(17);
    dk_ComplaintHeadLab.text = @"Customer service";
    [self.view addSubview:dk_ComplaintHeadLab];
    [dk_ComplaintHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(63)+DK_SafeAreaTop));
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(24)));
    }];
    self.dk_MainSiglePhoneView = [[DKMainSigleInfoView alloc] init];
    self.dk_MainSiglePhoneView.sigleInfoHead = @"Customer service hotline";
    [self.view addSubview:self.dk_MainSiglePhoneView];
    [self.dk_MainSiglePhoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dk_ComplaintHeadLab.mas_bottom).offset(DK_IsWidthScale(20));
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.height.equalTo(@(DK_IsWidthScale(165)));
    }];
    self.dk_MainSigleEmailView = [[DKMainSigleInfoView alloc] init];
    self.dk_MainSigleEmailView.sigleInfoHead = @"Customer service email";
    [self.view addSubview:self.dk_MainSigleEmailView];
    [self.dk_MainSigleEmailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.dk_MainSiglePhoneView.mas_bottom).offset(DK_IsWidthScale(10));
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.height.equalTo(@(DK_IsWidthScale(165)));
    }];
    NSString *complaintAlert = @"Please feedback with your name, phone number and app name, thanks!";
    NSMutableAttributedString*complaintAlertString = [[NSMutableAttributedString alloc] initWithString:complaintAlert attributes:@{NSFontAttributeName:DK_FONT_Regular(10),NSForegroundColorAttributeName:DK_Hex(@"#333333")}];
    [complaintAlertString addAttributes:@{NSForegroundColorAttributeName:DK_Hex(@"#FF0000")} range:NSMakeRange(20, 37)];
    UILabel * dk_ComplaintAlertLab = [[UILabel alloc] init];
    dk_ComplaintAlertLab.numberOfLines = 0;
    dk_ComplaintAlertLab.attributedText = complaintAlertString;
    [self.view addSubview:dk_ComplaintAlertLab];
    [dk_ComplaintAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.dk_MainSigleEmailView.mas_bottom).offset(DK_IsWidthScale(10));
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.height.equalTo(@(DK_IsWidthScale(14)));
    }];
    //协议
    UIButton * dk_AuthPrivacyAgreementBtn = [[UIButton alloc] init];
    [dk_AuthPrivacyAgreementBtn setTitle:@"《Privacy Agreement》" forState:UIControlStateNormal];
    [dk_AuthPrivacyAgreementBtn setTitleColor:DK_Hex(@"#CCCCCC") forState:UIControlStateNormal];
    dk_AuthPrivacyAgreementBtn.titleLabel.font = DK_FONT_Regular(12);
    [dk_AuthPrivacyAgreementBtn addTarget:self action:@selector(checkPrivacyAgreement) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dk_AuthPrivacyAgreementBtn];
    [dk_AuthPrivacyAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.bottom.equalTo(@(-DK_IsWidthScale(80)-DK_SafeAreaBottom));
        make.height.equalTo(@(DK_IsWidthScale(17)));
    }];
}
- (void)checkPrivacyAgreement{
    WeakSelf(self)
    DKWebViewController * dk_WebViewCtrl = [[DKWebViewController alloc] initWithUrl:DK_PrivacyAgreement withIsNavBar:YES];
    [weakSelf.navigationController pushViewController:dk_WebViewCtrl animated:YES];
}
- (void)requestComplaint{
    WeakSelf(self)
    [DKPublicHttp apiCustomerServiceInfoForAPI:@{} complete:^(DKCustomerServiceModel * _Nonnull customerServiceMdl) {
        weakSelf.dk_MainSiglePhoneView.sigleInfo = customerServiceMdl.phone;
        weakSelf.dk_MainSigleEmailView.sigleInfo = customerServiceMdl.email;
    }];
} 
@end
